package com.bbs.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 拦截service切面类
 */
@Component("myAspect")
@Aspect
public class MyAspect {
    //前置增强方法。在目标方法执行前执行
    @Before("execution(* com.bbs.service.impl.*.*(..))")
    public void before(){
        System.out.println("前置代码增强.....当前时间："+new SimpleDateFormat().format(new Date()));
    }

    // 后置增强方法，在目标方法执行完毕后执行
    //@After("execution(* com.service.*.*(..))")
    public void afterNotyfy(){
        System.out.println("后置代码增强.....当前时间："+new SimpleDateFormat().format(new Date()));
    }

    //@Around("execution(* com.service.*.*(..))")
    public void around(ProceedingJoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        System.out.println(args[0]);
    }
}
